package com.nami.web.facade.impl;

import com.nami.store.api.request.conversation.ConverPageReq;
import com.nami.store.api.service.RemoteConverService;
import com.nami.store.api.service.RemoteGroupService;
import com.nami.store.api.service.RemoteUserService;
import com.nami.store.api.response.conversation.ConverDetailVO;
import com.nami.web.dto.conver.ConverDTO;
import com.nami.web.facade.ConverFacadeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.common.json.utils.JsonUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.satoken.utils.LoginHelper;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@RequiredArgsConstructor
public class ConverFacadeServiceImpl implements ConverFacadeService {

    @DubboReference
    RemoteConverService remoteConverService;

    @DubboReference
    RemoteUserService remoteUserService;

    @DubboReference
    RemoteGroupService remoteGroupService;

    @Override
    public TableDataInfo<ConverDetailVO> getConver(ConverDTO converDTO) {
        log.info("[conver] 分页获取 request={}", JsonUtils.toJsonString(converDTO));
        String userId = LoginHelper.getUserIdStr();

        ConverPageReq request = new ConverPageReq();
        request.setAppKey(LoginHelper.getAppKey());
        request.setUserId(userId);
        request.setPageNum(converDTO.getPageNum());
        request.setPageSize(converDTO.getPageSize());
        return remoteConverService.getConverFromPage(request);
    }


}
